<template>
	<view class="orders">
		<!-- 顶部导航栏组件 -->
		<QSNavbar :navbarItems="navbarItems_1" backgroundColor="#fff" ref="navbar">
			<!-- <u-input prefixIcon="search" prefixIconStyle="font-size: 22px; color: #000" shape="circle"
				:value="searchValue" /> -->
			<u-search @search="search" @custom="search" placeholder="请输入检索内容" :showAction="false" v-model="searchKey">
			</u-search>
		</QSNavbar>

		<u-sticky :customNavHeight="navbarHeigth" v-if="navbarHeigth">
			<u-tabs :list="tabsList" lineColor="#4786fe" :activeStyle="{
          color: '#333',
        }" :inactiveStyle="{
          color: '#c2c1c1',
        }" :lineWidth="30" :current="currentTab" @click="onClickTab" />
			<!-- <u-swiper :list="list1" radius=0></u-swiper> -->
			<!-- <u-swiper :list="list2" keyName="image" circular :autoplay="true" @click="clicklist"></u-swiper> -->
		</u-sticky>
		<view class="" v-if="list1 != ''">
			<u-swiper :list="list1" radius=0></u-swiper>
		</view>

		<view class="orders-content">
			<!-- 广告 -->
			<!-- <view class="banner">
				<u-image width="100%" height="240rpx" radius="16rpx"></u-image>
			</view> -->

			<!-- 订单列表 -->
			<view class="orders-list" v-if="ordersList.length">
				<view v-for="item in ordersList" :key="item.id" class="orders-item">
					<!-- <view class="top flex-between" @click="Tobepaid(item ,index)"> -->
					<view class="top flex-between">
						<view class="flex-center">
							<!-- <u-image :src="item.venue.venue_thumb" width="40rpx" height="40rpx" shape="square">
							</u-image> -->
							<u-image :src="`${assetsPath}44d8d751bb60e10cc8e83c114d488541605662f5.png`" width="30rpx"
								height="30rpx" shape="square"></u-image>
							<view style="margin-left: 16rpx">{{
                item.venue.venue_name
              }}</view>
						</view>
						<view class="status">
							<view class="" v-if="item.order_status === 2"> 待付款 </view>
							<view class="done" v-else-if="item.order_status === 1">
								已支付
							</view>
							<view class="done" v-else-if="item.order_status === 3">
								已关闭
							</view>
							<view class="done" v-else-if="item.order_status === 4">
								已取消
							</view>
							<view class="done" v-else-if="item.order_status === 7">
								退款成功
							</view>
							<!-- <view v-for="its in item.withOrderItem2" :key="it.id"  v-else-if="its.order_status === 6">
								<view class="done" style="color: #ec7e2f;">
									退款中
								</view>
							</view> -->
						</view>
					</view>

					<block v-if="item.order_status != 2 ">
						<view class="it">
							<view v-for="it in item.withOrderItem2" :key="it.id" class="its">
								<view class="" style="font-size: 24rpx;display: flex;lex-direction: row;" v-if="it.order_type == 3">
									<view class="" >
										场地时间:{{it.time?it.time:''}}
									</view>
									<!-- <u-tooltip :text="it.order_item_id" overlay></u-tooltip> -->
								</view>
								<view class="" style="font-size: 24rpx;display: flex;lex-direction: row;" v-if="it.order_type == 3">
									<view class="">
										场地号:{{it.field_name?it.field_name:''}}
									</view>
									<!-- <u-tooltip :text="it.order_item_id" overlay></u-tooltip> -->
								</view>
								
								<view class="content d-flex">
									<u-image :src="it.goods_image" width="180rpx" height="180rpx" radius="16rpx" />

									<view class="right-content">
										<view class="flex-between">
											<view class="name ellipsis-2" style="width: 396rpx;">{{ it.goods_name }}
											</view>
											<view class="name ellipsis-2">×{{ it.goods_number }}</view>
										</view>
										<view>
											<!-- <view class="time">{{ it.consumption_type }}</view> -->
											<view class="flex-between">
												<price :value="it.deposit" :color="'#ffaa00'"></price>
												<view class="count">押金</view>
											</view>
										</view>
										<view>
											<!-- <view class="time">{{ it.consumption_type }}</view> -->
											<view class="flex-between">
												<price :value="it.goods_price" :color="'#ff4105'"></price>

												<view class="count" v-if="pay_complete != ''">{{ it.pay_complete }}
												</view>
												<view class="count" v-else>{{ it.create_at }}</view>
											</view>
										</view>
									</view>
								</view>
								<!-- <view class="" style="font-size: 24rpx;display: flex;flex-direction: column;"> -->
									<!-- <view class="">
										场地号:{{it.field_name}}号场
									</view> -->
									<!-- <view class="">
										场地号:{{it.time}}
									</view> -->
									
								<!-- </view> -->
								<view class="bottom" style="margin-bottom: 20rpx;">
									<!-- <view v-if="item.status === 2">
										<view class="flex-between">
											<text style="color: #5677fc"></text>
											<view class="d-flex">
												<u-button text="查看物流" shape="circle" plain color="#999999"></u-button>
												<u-button text="确认收货" shape="circle"
													color="linear-gradient(0deg, #528EFF, #2F75FA)"></u-button>
											</view>
										</view>
									</view> -->
									<view class="" style="display: flex; flex-direction: row;  justify-content: space-between;align-items: center; ">
										<view class="" style="display: flex; flex-direction: column;   ">
											<view class="" v-if="item.order_status === 2 ">
												<view style="color: #ec7e2f;font-size: 30rpx;">
													<view class="" style="margin-top: 20rpx;" v-if="item.numcard_id != 0">
														卡扣(
														{{ parseFloat(item.numcard_sub_price) + parseFloat(item.numcard_main_price )}} )
													</view>
													<view class="">
														应付:<text
															style="color: #ff4105;font-size: 34rpx;font-weight: bold;">{{ item.sum }}</text>
													</view>
												
												</view>
											</view>
											<view class="" v-if="item.order_status === 1">
												<view style="color: #ec7e2f;font-size: 30rpx;">
													<view class="" style="margin-top: 20rpx;" v-if="item.numcard_id != 0">
														卡扣(
														{{ parseFloat(item.numcard_sub_price) + parseFloat(item.numcard_main_price )}} )
													</view>
													<view class="">
														应付:<text
															style="color: #ff4105;font-size: 34rpx;font-weight: bold;">{{ item.sum }}</text>
													</view>
												
												</view>
											</view>
											<view class="" v-if="item.order_status === 7 ">
												<view style="color: #ec7e2f;font-size: 30rpx;">
													<view class="" style="margin-top: 20rpx;" v-if="item.numcard_id != 0">
														卡扣(
														{{ parseFloat(item.numcard_sub_price) + parseFloat(item.numcard_main_price )}} )
													</view>
													<view class="">
														应付:<text
															style="color: #ff4105;font-size: 34rpx;font-weight: bold;">{{ item.sum }}</text>
													</view>
												
												</view>
											</view>
										</view>
										<view class="">
											<view v-if="item.order_status === 1">
												<view class="flex-between">
													<text style="color: #5677fc"></text>
													<view class="d-flex">
														<u-button text="申请退单" @click="requestRefund(it)" shape="circle" plain
															v-if="it.order_status != 7 && !it.not_refund  " color="#999999">
														</u-button>
														<!-- <u-button text="去评价" @click="toComment(it)" shape="circle" color="linear-gradient(0deg, #528EFF, #2F75FA)"></u-button> -->
														<!-- 	<u-button text="查看评价" @click="toCommentList(item)" shape="circle"
														color="linear-gradient(0deg, #528EFF, #2F75FA)"></u-button> -->
														<!-- <u-button text="申请开票" @click="requestInvoicing(item)"
															v-if="it.order_status!=6 && it.order_status!=7" shape="circle"
															color="linear-gradient(0deg, #528EFF, #2F75FA)"></u-button> -->
														<!-- <u-button text="查看发票" shape="circle" color="linear-gradient(0deg, #528EFF, #2F75FA)"></u-button> -->
											
														<!--start 此处处理当申请退款到退款成功之间的时间，订单处于已支付下，或者多个子订单中其中一个子订单退款状态 -->
														<view style="color: #ec7e2f;margin-bottom: 18rpx;"
															v-if="it.order_status===6">
															退款中
														</view>
											
														<!--end 此处处理当申请退款到退款成功之间的时间，订单处于已支付下，或者多个子订单中其中一个子订单退款状态 -->
													</view>
												</view>
											</view>
											<view v-if="item.order_status === 7" style="position: absolute;right: 76rpx;">
												<!-- <view class="flex-between"> -->
												<text style="color: #5677fc"></text>
												<!-- <view class="d-flex"> -->
												<view style="color: #70d18c;" v-if="it.order_status===7">
													已退款
												</view>
												<!--end 此处处理当申请退款到退款成功之间的时间，订单处于已支付下，或者多个子订单中其中一个子订单退款状态 -->
												<!-- </view> -->
												<!-- </view> -->
											</view>
											
											<!-- <view v-if="item.status === 4">
												<view class="flex-between">
													<text style="color: #5677fc"></text>
													<view class="d-flex">
														<u-button text="查看评价" shape="circle" plain
															color="linear-gradient(0deg, #528EFF, #2F75FA)"></u-button>
														<u-button text="查看退单" shape="circle" plain
															color="linear-gradient(0deg, #528EFF, #2F75FA)"></u-button>
														<u-button text="查看开票" shape="circle" plain
															color="linear-gradient(0deg, #528EFF, #2F75FA)"></u-button>
													</view>
												</view>
											</view> -->
										</view>
									</view>
								</view>
								
							</view>
						</view>
					</block>


					<block v-if="item.order_status === 2">
						<view class="it">
							<!--详情页面待支付 @click="Tobepaid(item ,index)" -->
							<view v-for="it in item.withOrderItem2" :key="it.id" class="its">
								<view class="" style="font-size: 24rpx;display: flex;lex-direction: row;align-items: center;">
									<view class="">
										订单号:
									</view>
									<u-tooltip :text="it.order_item_id" overlay></u-tooltip>
								</view>
								<view class="content d-flex">
									<u-image :src="it.goods_image" width="180rpx" height="180rpx" radius="16rpx" />

									<view class="right-content">
										<view class="flex-between">
											<view class="name ellipsis-2">{{ it.goods_name }}</view>
										</view>
										<view>
											<!-- <view class="time">{{ it.consumption_type }}</view> -->
											<view class="flex-between">
												<price :value="it.deposit" :color="'#ffaa00'"></price>
												<view class="count">押金</view>
											</view>
										</view>
										<view>
											<!-- <view class="time">{{ it.consumption_type }}</view> -->
											<view class="flex-between">
												<price :value="it.goods_price" :color="'#ff4105'"></price>
												<view class="count">×{{ it.goods_number }}</view>
											</view>
										</view>
									</view>
								</view>
							</view>
							
							<view class="" style="display: flex; flex-direction: row;  justify-content: space-between; align-items: center;">
								<view class="" style="display: flex; flex-direction: column;   ">
									<view class="" v-if="item.order_status === 2 ">
										<view style="color: #ec7e2f;font-size: 30rpx;">
											<view class="" style="margin-top: 20rpx;" v-if="item.numcard_id != 0">
												卡扣(
												{{ parseFloat(item.numcard_sub_price) + parseFloat(item.numcard_main_price )}} )
											</view>
											<view class="">
												应付:<text
													style="color: #ff4105;font-size: 34rpx;font-weight: bold;">{{ item.sum }}</text>
											</view>
										
										</view>
									</view>
									<view class="" v-if="item.order_status === 1">
										<view style="color: #ec7e2f;font-size: 30rpx;">
											<view class="" style="margin-top: 20rpx;" v-if="item.numcard_id != 0">
												卡扣(
												{{ parseFloat(item.numcard_sub_price) + parseFloat(item.numcard_main_price )}} )
											</view>
											<view class="">
												应付:<text
													style="color: #ff4105;font-size: 34rpx;font-weight: bold;">{{ item.sum }}</text>
											</view>
										
										</view>
									</view>
									<view class="" v-if="item.order_status === 7 ">
										<view style="color: #ec7e2f;font-size: 30rpx;">
											<view class="" style="margin-top: 20rpx;" v-if="item.numcard_id != 0">
												卡扣(
												{{ parseFloat(item.numcard_sub_price) + parseFloat(item.numcard_main_price )}} )
											</view>
											<view class="">
												应付:<text
													style="color: #ff4105;font-size: 34rpx;font-weight: bold;">{{ item.sum }}</text>
											</view>
										
										</view>
									</view>
								</view>
								<view class="">
									<view class="bottom">
										<view v-if="item.order_status === 2">
											<view class="flex-between">
												<text style="color: #5677fc"></text>
												<!-- <view style="color: #ec7e2f">合计: <text
												style="color: #ff4105;margin-top: -110rpx;font-size: 34rpx;font-weight: bold;">{{ item.sum }}</text></view> -->
												<view class="d-flex">
													<u-button text="取消订单" shape="circle" plain color="#999999"
														@click="Refund(item)"></u-button>
													<u-button text="去支付" shape="circle" @click="createOrder(item)"
														color="linear-gradient(0deg, #528EFF, #2F75FA)"></u-button>
												</view>
											</view>
										</view>
									
									</view>
								</view>
							</view>
							
						</view>
					</block>
					<!-- <view class="bottom" style="margin:0;padding-bottom: 10rpx;">
						<view >
							<view class="flex-between">
								<view style="color: #ec7e2f;margin-top: -110rpx;font-size: 30rpx;">合计:
									<text
										style="color: #ff4105;margin-top: -110rpx;font-size: 34rpx;font-weight: bold;">{{ item.sum }}</text>
								</view>
							</view>
						</view>
					</view> -->
					<!-- <view class="" style="display: flex; flex-direction: row;  justify-content: space-between; ">
						<view class="" style="display: flex; flex-direction: column;   ">
							<view class="" v-if="item.order_status === 2 ">
								<view style="color: #ec7e2f;font-size: 30rpx;">
									<view class="" style="margin-top: 20rpx;" v-if="item.numcard_id != 0">
										卡扣(
										{{ parseFloat(item.numcard_sub_price) + parseFloat(item.numcard_main_price )}} )
									</view>
									<view class="">
										应付:<text
											style="color: #ff4105;font-size: 34rpx;font-weight: bold;">{{ item.sum }}</text>
									</view>
								
								</view>
							</view>
							<view class="" v-if="item.order_status === 1">
								<view style="color: #ec7e2f;font-size: 30rpx;">
									<view class="" style="margin-top: 20rpx;" v-if="item.numcard_id != 0">
										卡扣(
										{{ parseFloat(item.numcard_sub_price) + parseFloat(item.numcard_main_price )}} )
									</view>
									<view class="">
										应付:<text
											style="color: #ff4105;font-size: 34rpx;font-weight: bold;">{{ item.sum }}</text>
									</view>
								
								</view>
							</view>
							<view class="" v-if="item.order_status === 7 ">
								<view style="color: #ec7e2f;font-size: 30rpx;">
									<view class="" style="margin-top: 20rpx;" v-if="item.numcard_id != 0">
										卡扣(
										{{ parseFloat(item.numcard_sub_price) + parseFloat(item.numcard_main_price )}} )
									</view>
									<view class="">
										应付:<text
											style="color: #ff4105;font-size: 34rpx;font-weight: bold;">{{ item.sum }}</text>
									</view>
								
								</view>
							</view>
						</view>
						<view class=""  style="display: flex; flex-direction: row;  justify-content: flex-start; ">
							
						</view>
					</view> -->
					<!-- <view class="bottom" style="margin:0; " v-if="item.order_status === 2 ">
						<view>
							<view class="flex-between">
								<view style="color: #ec7e2f;font-size: 30rpx;">
									<view class="" style="margin-top: 20rpx;" v-if="item.numcard_id != 0">
										卡扣(
										{{ parseFloat(item.numcard_sub_price) + parseFloat(item.numcard_main_price )}} )
									</view>
									<view class="">
										应付:<text
											style="color: #ff4105;font-size: 34rpx;font-weight: bold;">{{ item.sum }}</text>
									</view>

								</view>
							</view>
						</view>
					</view>
					<view class="bottom" style="margin:0;" v-if=" item.order_status === 1 ">
						<view>
							<view class="flex-between">
								<view style="color: #ec7e2f;font-size: 30rpx;">
									<view class="" style="margin-top: 80rpx;" v-if="item.numcard_id != 0">
										卡扣(
										{{ parseFloat(item.numcard_sub_price) + parseFloat(item.numcard_main_price) }} )
									</view>
									<view class="">
										实付:<text
											style="color: #ff4105;font-size: 34rpx;font-weight: bold;">{{ item.sum }}</text>
									</view>

								</view>
							</view>
						</view>
					</view>
					<view class="bottom" style="margin:0;padding-bottom: 20rpx " v-if="item.order_status === 7 ">
						<view>
							<view class="flex-between">
								<view style="color: #ec7e2f;font-size: 30rpx;">
									<view class="" style="margin-top: 20rpx;" v-if="item.numcard_id != 0">
										卡扣(
										{{parseFloat(item.numcard_sub_price) + parseFloat(item.numcard_main_price) }} )
									</view>
									<view class="">
										实付:<text
											style="color: #ff4105;font-size: 34rpx;font-weight: bold;">{{ item.sum }}</text>
									</view>

								</view>
							</view>
						</view>
					</view> -->
				</view>
			</view>

			<u-empty v-else mode="coupon" icon="https://sass-test.doit10019.com/upload/202501/08114139-33838600519097990.jpg?attname=coupon.jpg" />
		</view>
	</view>
</template>

<script>
	import QSNavbar from "@/components/QS-Navbar/QS-Navbar.vue";
	const person = require("@/api/personal/index.js");
	const venues = require("@/api/venues/venues.js");
	/*
		状态
		1：待付款
		2：未完成
		3：已完成
		4：售后
	*/
	export default {
		components: {
			QSNavbar,
		},
		data() {
			return {
				// list2: [{
				// 	image: 'https://cdn.uviewui.com/uview/swiper/swiper2.png',
				// 	value:'111',
				// 	url:'https://www.uviewui.com/'
				// }, {
				// 	image: 'https://cdn.uviewui.com/uview/swiper/swiper1.png',
				// 	value:'222',
				// 	url:'https://uniapp.dcloud.net.cn/'
				// }, {
				// 	image: 'https://cdn.uviewui.com/uview/swiper/swiper3.png',
				// 	value:'333',
				// 	url:'https://www.baidu.com/'
				// }],
				list1: [],
				assetsPath: this.$https.assetsPath,
				navbarHeigth: null,
				currentTab: 0,
				navbarItems_1: [{
					type: "icon",
					icon: "left",
					layout: "left",
					width: 15,
					iconColor: "#000",
					// doEvent: "back",
					doEvent: "navigateTo",
					// targetPath:'/pages/personal/personal'
				}, ],
				tabsList: [{
						name: "全部订单"
					},
					{
						name: "待付款"
					},
					// {
					// 	name: "未完成"
					// },
					{
						name: "已付款"
					},
					{
						name: "退款/取消"
					},
				],
				searchValue: "",
				ordersList: [],
				searchKey: "", //搜索关键词
				val: '', //关键词
				orderStatus: '',
				listQuery: { //分页
					pageNo: 1,
					pageSize: 6,
				},
				totalPage: '', //几页
				empty_s: false,
				goods_type: '',
				ticketData: {},
				amountValue: 1,
				spec: "",
				order_remarks: '',
				train_price: "0.00",
				lop: ""
			};
		},
		computed: {
			_ordersList() {
				return this.currentTab === 0 ?
					this.ordersList :
					this.ordersList.filter((i) => i.status === this.currentTab);
			},
		},
		onLoad({
			tab = 0
		}) {
			this.listQuery.pageNo = 1
			this.ordersList = [];
			this.currentTab = Number(tab);
			if (this.currentTab === 1) {
				// this.getOrdersList(2);
				this.orderStatus = '2'
			}
			//  else if (this.currentTab === 2) {
			// 	// this.getOrdersList(3);
			// 	this.orderStatus = '3'
			// }
			else if (this.currentTab === 2) {
				// this.getOrdersList(1);
				this.orderStatus = '1'
			} else if (this.currentTab === 3) {
				// this.getOrdersList(5);
				this.orderStatus = '14' // 6 退款中/7 退款成功状态
			} else {
				// this.getOrdersList("all");
				this.orderStatus = 'all'
			}
			this.getOrdersList();
			this.getChannelBanner()

		},
		onReady() {
			this.$refs.navbar.getQuery((res) => {
				this.navbarHeigth = res.height;
			});
		},
		onShow() {
			// let that = this;
			// that.listQuery.pageNo = 1
			// that.ordersList = [];
			// that.getOrdersList()
		},
		methods: {
			// 轮播跳转外部链接
			clicklist(index) {
				this.lop = index
				this.list2.forEach((item1, index2) => {
					if (index == index2) {
						let link_url = item1.url
						uni.navigateTo({
							url: `/page_points/webview/webview?url=${link_url}`
						})
					}
				})
			},
			// 获取我的待付款订单
			async getChannelBanner() {
				let postData = {
					app_id: this.$https.weixinAppId,
					project_id: getApp().globalData.projectId,
				};
				let res = await person.getChannelBanner(postData);
				if (res.code == 1) {
					this.list1 = res.data.result.channel_banner_order
				}
			},
			onClickTab({
				index
			}) {
				this.currentTab = index;
				this.ordersList = [];
				this.listQuery.pageNo = 1

				if (this.currentTab === 1) {
					this.ordersList = [];
					this.orderStatus = '2'

				} else if (this.currentTab === 2) {
					this.ordersList = [];
					// this.orderStatus = '3'
					this.orderStatus = '1'
				} else if (this.currentTab === 3) {
					this.ordersList = [];
					// this.orderStatus = '1'
					this.orderStatus = '14'
				} else if (this.currentTab === 4) {
					this.ordersList = [];
					// this.orderStatus = '5'
					this.orderStatus = '3'
				} else {
					this.ordersList = [];
					this.orderStatus = 'all'
				}
				this.getOrdersList();
			},
			toComment(item) {
				uni.navigateTo({
					url: `/pages_a/comment/comment?id=${item.id}`,
				});
			},
			toCommentList(item) {
				uni.navigateTo({
					url: `/pages_a/comment/comment-list/comment-list?id=${item.id}`,
				});
			},
			requestInvoicing(item) {
				uni.navigateTo({
					url: `/pages_a/invoicing/invoicing?id=${item.id}`,
				});
			},
			// 获取我的待付款订单
			async Refund(item) {
				let postData = {
					project_id: getApp().globalData.projectId,
					app_id: this.$https.weixinAppId,
					order_id: item.id,
				};
				let res = await venues.checkOrderStatusBeforePay(postData);
				if (res.code == 1) {
					if (res.data.result == '') {
						let that = this;
						let postData = {
							app_id: this.$https.weixinAppId,
							project_id: getApp().globalData.projectId,
							order_id: item.id,
							reason: '',

						};
						uni.showModal({
							title: '提示',
							// 提示文字
							content: '是否取消订单？',
							// 取消按钮的文字自定义
							cancelText: "提交",
							// 确认按钮的文字自定义
							confirmText: "我再想想",
							//删除字体的颜色 
							confirmColor: '#000000',
							//取消字体的颜色
							cancelColor: '#999',
							success: function(res) {
								if (res.confirm) {
									// 执行确认后的操作
								} else {
									person.Refund(postData).then(result => {
										if (result.code == 1) {
											uni.navigateTo({
												url: '/pages/personal/orders/orders?tab=1'
											})
										}
									})
								}
							}
						})
					} else {
						uni.showModal({
							title: '该订单已取消',
							// 提示文字
							// content: '是否取消订单？',
							// 取消按钮的文字自定义
							cancelText: "取消",
							// 确认按钮的文字自定义
							confirmText: "我知道了",
							//删除字体的颜色 
							confirmColor: '#000000',
							//取消字体的颜色
							cancelColor: '#999',
							success: function(res) {
								// 执行确认后的操作
								uni.navigateTo({
									url: '/pages/personal/orders/orders?tab=1',
								});
							}
						})
					}
				}

			},
			requestRefund(it) {
				var that = this
				if (uni.getStorageSync("refund_success") != '' && uni.getStorageSync("refund_success") !=
					null && uni.getStorageSync("refund_success") != undefined) {
					uni.requestSubscribeMessage({
						tmplIds: [uni.getStorageSync("refund_success")],
						success(res) {
							/* uni.navigateTo({
								url: `/pages_a/refund/refund?id=${it.id}&goods_name=${it.goods_name}&amount_payable=${it.amount_payable}&orderlength=${it.order_item_length}&consumption_type=${it.consumption_type}&order_money=${it.order_money}&pay_method=${it.pay_method}&goods_image=${it.goods_image}`,
							}); */
							if (res.errMsg == 'requestSubscribeMessage:ok') {
								uni.redirectTo({
									url: "/pages_a/refund/refund?id=" + it.id + '&goods_name=' + it
										.goods_name + '&amount_payable=' + it.amount_payable +
										'&orderlength=' + it.order_item_length + '&consumption_type=' + it
										.consumption_type + '&order_money=' + it.order_money +
										'&pay_method=' +
										it.pay_method + '&goods_image=' + it.goods_image,
								})
							}

						},
						fail(err) {
							uni.showModal({
								title: '提示',
								// 提示文字
								content: '您退款太过频繁，请稍后再试',
								// 取消按钮的文字自定义
								cancelText: "取消",
								// 确认按钮的文字自定义
								confirmText: "确认",
								//删除字体的颜色
								confirmColor: '#000000',
								//取消字体的颜色
								cancelColor: '#999',
								success: function(res) {

								}

							})
						}
					})
				} else {
					uni.redirectTo({
						url: "/pages_a/refund/refund?id=" + it.id + '&goods_name=' + it
							.goods_name + '&amount_payable=' + it.amount_payable +
							'&orderlength=' + it.order_item_length + '&consumption_type=' + it
							.consumption_type + '&order_money=' + it.order_money + '&pay_method=' +
							it.pay_method + '&goods_image=' + it.goods_image,
					})
				}
				// 	uni.requestSubscribeMessage({
				// 		tmplIds: ['R3prlifwIbScJTer8rlTpDaJE0tTRJ567oMtSsGmhek'],
				// 		success(res) {
				// 			/* uni.navigateTo({
				// 				url: `/pages_a/refund/refund?id=${it.id}&goods_name=${it.goods_name}&amount_payable=${it.amount_payable}&orderlength=${it.order_item_length}&consumption_type=${it.consumption_type}&order_money=${it.order_money}&pay_method=${it.pay_method}&goods_image=${it.goods_image}`,
				// 			}); */
				// 			if (res.errMsg == 'requestSubscribeMessage:ok') {
				// 				uni.redirectTo({
				// 					url: "/pages_a/refund/refund?id=" + it.id + '&goods_name=' + it
				// 						.goods_name + '&amount_payable=' + it.amount_payable +
				// 						'&orderlength=' + it.order_item_length + '&consumption_type=' + it
				// 						.consumption_type + '&order_money=' + it.order_money + '&pay_method=' +
				// 						it.pay_method + '&goods_image=' + it.goods_image,
				// 				})
				// 			} else {
				// 			}

				// 		},
				// 		fail(err) {
				// 			uni.showModal({
				// 				title: '提示',
				// 				// 提示文字
				// 				content: '您退款太过频繁，请稍后再试',
				// 				// 取消按钮的文字自定义
				// 				cancelText: "取消",
				// 				// 确认按钮的文字自定义
				// 				confirmText: "确认",
				// 				//删除字体的颜色
				// 				confirmColor: '#000000',
				// 				//取消字体的颜色
				// 				cancelColor: '#999',
				// 				success: function(res) {

				// 				}

				// 			})
				// 		}
				// 	})

			},
			// 获取我的待付款订单
			async getOrdersList() {
				let that = this;
				if (this.listQuery.pageNo === 1) that.ordersList = [];
				// uni.showLoading({
				// 	title: "加载中...",
				// 	mask: true,
				// });
				let postData = {
					app_id: this.$https.weixinAppId,
					project_id: getApp().globalData.projectId,
					owner: uni.getStorageSync("phone"),
					orderStatus: this.orderStatus,
					search_field: this.val,
					page: this.listQuery.pageNo,
					limit: this.listQuery.pageSize,
				};
				let res = await person.getMyOrder(postData);
				// this.$nextTick(() => {
				// 	uni.hideLoading();
				// });
				if (res.code == 1) {
					that.ordersList = that.ordersList.concat(res.data.data.data); //将数据拼接在一起
					that.totalPage = res.data.data.last_page
				} else if (res.code == 0) {
					// this.$ui.toast(res.msg);
					this.ordersList = []
					this.empty_s = true

				}
			},
			// 下拉刷新
			onReachBottom() {
				// uni.showLoading({
				// 	title: '加载中'
				// });
				if (this.totalPage <= this.listQuery.pageNo) {
					// uni.hideLoading();
					uni.showToast({
						title: '没有更多了',
						duration: 2000,
						icon: 'none'
					});
					return
				}
				this.listQuery.pageNo += 1;
				this.getOrdersList()
			},
			// 跳转详情
			Tobepaid(item, index) {
				if (item.order_status === 2) { // 待支付
					uni.navigateTo({
						url: `/page_venues/pages/venuesDetail/paidDetail/paidDetail?id=${item.id}`,
					})
				}
				// else if (item.order_status === 3) { // 未完成
				// 	uni.navigateTo({
				// 		url: '/page_venues/pages/venuesDetail/paidDetail/unpaidDetail'
				// 	})
				// } else if (item.order_status === 1) { // 已完成
				// 	uni.navigateTo({
				// 		url: '/page_venues/pages/venuesDetail/paidDetail/completedDetail'
				// 	})
				// }
			},
			// 搜索字
			search(val) {
				this.val = val
				this.page = 1;
				this.ordersList = [];
				this.status = "loading";
				this.getOrdersList();
			},

			// 去支付
			// 金额计算保留两位小数
			amount(value) {
				return parseFloat(value).toFixed(2);
			},
			async createOrder(item) {
				let postData = {
					project_id: getApp().globalData.projectId,
					app_id: this.$https.weixinAppId,
					order_id: item.id,
				};
				let res = await venues.checkOrderStatusBeforePay(postData);
				if (res.code == 1) {
					if (res.data.result == '') {
						var that = this;
						uni.redirectTo({
							url: "/page_venues/pages/venuesDetail/pay/pay?amount=" +
								item.sum +
								"&payWaitTime=" +
								item.pay_waiting_time +
								"&venue_id=" +
								item.venue_id +
								"&order_id=" +
								item.order_id +
								"&orderid=" +
								item.id +
								"&chaoshitype=" +
								2 +
								"&order_type=" +
								item.order_type +
								"&classNum=" +
								item.classNum +
								"&train_price=" +
								item.train_price +
								"&goods_id=" +
								item.withOrderItem2[0].goods_id,
						});
					} else {
						uni.showModal({
							title: '该订单已取消',
							// 提示文字
							// content: '是否取消订单？',
							// 取消按钮的文字自定义
							cancelText: "取消",
							// 确认按钮的文字自定义
							confirmText: "我知道了",
							//删除字体的颜色 
							confirmColor: '#000000',
							//取消字体的颜色
							cancelColor: '#999',
							success: function(res) {
								// 执行确认后的操作
								uni.navigateTo({
									url: '/pages/personal/orders/orders?tab=1',
								});
							}
						})
					}
				}
			}
		},
	};
</script>

<style lang="scss" scoped>
	.orders {
		background-color: #f1f2f2;
		min-height: 100vh;
		padding-bottom: env(safe-area-inset-bottom);
		
		
		/deep/.u-tabs {
			background-color: #fff;

			.u-tabs__wrapper__nav__item {
				flex: 1;
			}

			.u-tabs__wrapper__nav__line {
				bottom: 0;
			}
		}

		/deep/.u-input {
			height: 100%;
			border-color: #2f75fa !important;
		}

		.orders-content {
			padding: 20rpx 40rpx;
		}

		.orders-item {
			background-color: #fff;
			border-radius: 20rpx;
			padding: 30rpx 24rpx 0;

			&+.orders-item {
				margin-top: 20rpx;
			}

			.not-done {
				color: #ff4207;
			}

			.status {
				white-space: nowrap;
				margin-left: 10rpx;
			}

			.it {
				padding: 24rpx 0;
			}

			.its {
				// padding: 24rpx 0;
				// padding: 0 0 24rpx 0;
			}

			.content {
				margin-top: 20rpx;

				.right-content {
					margin-left: 24rpx;
					display: flex;
					justify-content: space-between;
					flex-direction: column;
					flex: 1;
					font-size: 28rpx;
					color: rgb(51, 51, 51);
				}

				.time {
					padding: 0 24rpx;
					background-color: rgb(243, 243, 243);
					display: inline-block;
					border-radius: 100px;
					margin-bottom: 10rpx;
				}

				.price {
					.rmb {
						font-size: 24rpx;
					}

					.big {
						font-size: 36rpx;
						color: #ff4207 !important;
					}
				}
			}

			.bottom {
				font-size: 24rpx;
				// margin-top: 30rpx;

				/deep/.u-button {
					width: 160rpx;
					height: 60rpx;
					line-height: 60rpx;

					&+.u-button {
						margin-left: 20rpx;
					}
				}
			}
		}
	}
</style>